﻿using StockholmsStad.Windows.UI.Modules.Maintenance.Controls;
using StockholmsStad.Windows.UI.Modules.Maintenance.Interfaces;
using StockholmsStad.Windows.UI.Modules.Maintenance.Models;

namespace StockholmsStad.Windows.UI.Modules.Maintenance.Views
{
    /// <summary>
    /// Interaction logic for TabItemCeremonySettingsView.xaml
    /// </summary>
    public partial class TabItemCeremonySettingsView : ICeremonySettingsView
    {
        private readonly ICeremonySettingsService ceremonyService;

        public TabItemCeremonySettingsView(ICeremonySettingsService service) 
        {
            InitializeComponent();

            ceremonyService = service;

            Loaded += TabItemCeremonySettingsView_Loaded;
            Model = new CeremonyValuesPresentationModel();
        }

        void TabItemCeremonySettingsView_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            InitializeControls();
        }

        private void InitializeControls()
        {
            var propertiesControl = new CeremonyPropertiesControl();
            propertiesControl.Model = ceremonyService.GetParvisProperties();
            TabItemProperties.Content = propertiesControl;

            var ceremonyValuesControl = new CeremonyValuesControl();
            ceremonyValuesControl.Model = ceremonyService.GetCeremonyValues();
            TabItemCeremonyValues.Content = ceremonyValuesControl;
        }

        #region ICeremonySettingsView Members

        public CeremonyValuesPresentationModel Model 
        {
            get { return DataContext as CeremonyValuesPresentationModel; }
            set { DataContext = value; }
        }

        #endregion
    }
}
